<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>



<script>
window.onload = function(){
    //求n个数的累加
    function getSum(n){
        if ( n === 1 ) {
            return 1;
        }
        var sum = n + getSum(n-1);
        return sum;
    }
    console.log(getSum(10));
    //求n的阶乘
    function getJC(n){
        if( n === 1 ){
            return 1;
        }
        var jc = n * getJC(n-1);
        return jc;
    }

    console.log(getJC(2));
    //求Fibonacci的第n个数1 1 2 3 5 8 13 21
    function getFib(n){
        if( n === 1 || n === 2 ){
            return 1;
        }
        var fib = getFib(n-1) + getFib(n-2);
        return fib;
    }

    console.log(getFib(6));


}



</script>

</body>
</html>